package appopay.common;

import freemarker.template.TemplateException;
import pro.shuangxi.anno.Comment;
import pro.shuangxi.generator.Generator;
import pro.shuangxi.source.JpaClazzMapSource;
import pro.shuangxi.source.MapSource;

import javax.persistence.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * @author mengshx
 **/
public class CodeGeneratorClazz {


    public static void main(String[] args) throws IOException, TemplateException {
        List<Class<?>> asList = Arrays.asList(Template.class);
        for (Class<?> clazz : asList) {
            MapSource source = new JpaClazzMapSource(clazz);
            source.getMap().put("package", "pro.shuangxi.module.chatGpt");
            source.getMap().put("author", "mengshx");
            String projectPath = System.getProperty("user.dir");
            Generator generator = new Generator(source);
//            generator.setOutputPath(projectPath+"/src/main/java/pro/shuangxi/core/system");
            generator.setOutputPath(projectPath + "/render");
//            generator.setOutputPath("C:\\Users\\doublexi\\Desktop\\freelancer\\workplace\\appopay\\ng-framework\\src\\app\\pages\\product-category-manage");
            generator.render(projectPath + "/template_shuangxi_adminv2");
        }


    }


    @Entity
    @Table(name = "gpt_robot")
    @Comment("gpt_robot")
    static class Template {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id")
        @Comment("pk")
        private Long id;

        @Column(name = "robot_name")
        @Comment("机器人名字")
        private String robotName;

        @Column(name = "robot_setting")
        @Comment("机器人设定")
        private String robotSetting;

    }
}
